<template>
  <div>
    <h1>这是院系管理界面</h1>
    <el-card>
      <div class="container">
        <el-form :inline="true" :model="conditionModel">
          <el-form-item label="院系名称 ">
            <el-input v-model="conditionModel.facultyName" placeholder="请输入内容" style="width: 150px" ></el-input>
          </el-form-item>
          <el-form-item label="院长">
            <el-select v-model="conditionModel.facultyPresidentNo" clearable placeholder="请选择" @visible-change="searchPresidentNo">
              <el-option
                  v-for="item in supplierPresidentNo"
                  :key="item.techId"
                  :label="item.techName"
                  :value="item.techId">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="所属学部">
            <el-select v-model="conditionModel.departMentNo" clearable placeholder="请选择" @visible-change="searchDepartMentNo">
              <el-option
                  v-for="item in supplierDepartMentNo"
                  :key="item.departmentNo"
                  :label="item.departmentName"
                  :value="item.departmentNo">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item  label="状态">
            <el-select v-model="conditionModel.status" placeholder="请选择" style="width: 150px">
              <el-option
                  v-for="status in statusOptions"
                  :key="status.value"
                  :label="status.label"
                  :value="status.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item >
            <el-button type="primary" @click="searchCondition">搜索</el-button>
          </el-form-item>
          <el-form-item >
            <el-button type="primary" @click="reset">重置</el-button>
          </el-form-item>
        </el-form>

      </div>
      <el-table
          :data="tableData"
          style="width: 100%"
          border
      >
        <el-table-column
            prop="facultyId"
            label="id"
            width="120"
            align="center">
        </el-table-column>
        <el-table-column
            prop="facultyNo"
            label="院系编号"
            width="120"
            align="center">
        </el-table-column>
        <el-table-column
            prop="facultyName"
            label="院系名称"
            width="120"
            align="center">
        </el-table-column>
        <el-table-column
            prop="facultyPresident"
            label="院长"
            width="130"
            align="center">
        </el-table-column>
        <el-table-column
            prop="facultyDescription"
            label="学院描述"
            align="center">
        </el-table-column>
        <el-table-column
            prop="departmentName"
            label="所属学部"
            width="140"
            align="center">
        </el-table-column>
        <el-table-column
            prop="status"
            label="学籍状态"
            width="180"
            align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 1" type="success" size="medium">正常</el-tag>
            <el-tag v-if="scope.row.status === 2" type="warning" size="medium">暂停</el-tag>
            <el-tag v-if="scope.row.status === 3" type="danger" size="medium">撤销</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="pageIndex"
          :page-sizes="[5, 10, 20, 30]"
          :page-size.sync="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total.sync="total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
  import {facultyInfo,departMentInfo,positionInfo} from "@/api/discipline/faculty/info"
export default {
  name: "FacultyInfo",
  data:()=>({
    tableData:[],
    pageIndex:1,
    pageSize:10,
    total:10,
    //学部集合
    supplierDepartMentNo:{},
    //院长集合
    supplierPresidentNo:{},
    //专业状态
    statusOptions:[{
      label: '所有',
      value: ''
    },{
      label: '正常',
      value: '1'
    },{
      label: '暂停',
      value: '2'
    },{
      label: '撤销',
      value: '3'
    }],
    conditionModel:{
      facultyName : '',
      facultyPresidentNo : '',
      departMentNo : '',
      status : ''
    }
  }),
  methods:{
    //分页显示学生信息内容
    showAllFaculty(){
      let params = {
        facultyName : this.conditionModel.facultyName,
        facultyPresidentNo : this.conditionModel.facultyPresidentNo,
        departmentNo : this.conditionModel.departMentNo,
        status : this.conditionModel.status,
        pageIndex : this.pageIndex,
        pageSize : this.pageSize,
      }
      facultyInfo(params).then(response => {
        this.tableData = response.data.list ;
        this.pageSize = response.data.pageSize;
        this.pageIndex = response.data.pageNum;
        this.total = response.data.total;
      })
    },
    //所在尺寸改变时
    handleSizeChange(){
      this.showAllFaculty();
    },
    //所在页码改变时
    handleCurrentChange(){
      this.showAllFaculty();
    },
    //查询部门信息
    searchDepartMentNo() {
      departMentInfo().then(response =>{
        this.supplierDepartMentNo = response.data
      })
    },
    //查询院长信息
    searchPresidentNo(){
      positionInfo().then(response =>{
        console.log(response)
        this.supplierPresidentNo = response.data.list
      })
    },
    //条件查询信息
    searchCondition(){
      this.pageIndex = 1;
      this.showAllFaculty();
    },
    reset(){
      this.conditionModel={}
      this.supplierFaculty=[]
      this.showAllFaculty()
    }
  },
  created() {
    this.showAllFaculty()
  }
}
</script>

<style scoped>

</style>
